//
//  TodayEarningsStore.m
//  NewPro
//
//  Created by RYX on 2019/1/17.
//  Copyright © 2019 何荧红. All rights reserved.
//

#import "TodayEarningsStore.h"
#import "TodayEarningsModel.h"
#import "IncomeListModel.h"
#import "BackTotalModel.h"

@implementation TodayEarningsStore

#pragma mark - 今日收益头部数据
- (void)getTodayEarningsHeaderInfoWithYear:(NSString *)year month:(NSString *)month day:(NSString *)day Success:(void(^)(TodayEarningsModel *model))success Failure:(void(^)(NSError *error))failure{
    
    NSString *url = [NSString stringWithFormat:@"%@/api/v1/transAgg",IP];
    NSDictionary *dic = @{
                          @"year":year,
                          @"month":month,
                          @"day":day
                          };
    
    [HttpTool getUrlWithString:url parameters:dic success:^(id responseObject) {
        
        NSError *error = [HttpTool inspectError:responseObject];
        if (error == nil) {
            
            TodayEarningsModel *model = [TodayEarningsModel mj_objectWithKeyValues:responseObject[@"data"]];
            success(model);
        }else{
            
            failure(error);
        }
    } failure:^(NSError *error) {
        
        failure(error);
    }];
    
}
#pragma mark 当日收益机具奖励
- (void)getAllPosWithPrams:(NSDictionary *)prams Success:(void(^)(NSArray *listArr))success Failure:(void(^)(NSError *error))failure{
    NSString *url = [NSString stringWithFormat:@"%@/api/reward/today",IP];
    [HttpTool getUrlWithString:url parameters:prams success:^(id responseObject) {
        NSError *error = [HttpTool inspectError:responseObject];
        if (error == nil) {
            NSArray *arr = responseObject[@"data"];
            success(arr);
        }else{
            failure(error);
        }
    } failure:^(NSError *error) {
        failure(error);
    }];
}

#pragma mark - 推广奖励
- (void)getTGJLListWithYear:(NSString *)year month:(NSString *)month day:(NSString *)day current:(NSString *)current size:(NSString *)size Success:(void(^)(NSArray *listArr))success Failure:(void(^)(NSError *error))failure{
    
    NSString *url = [NSString stringWithFormat:@"%@/api/v1/trans/promotion",IP];
    NSDictionary *dic = @{
                          @"year":year,
                          @"month":month,
                          @"day":day,
                          @"current":current,
                          @"size":size
                          };
    
    [HttpTool getUrlWithString:url parameters:dic success:^(id responseObject) {
        
        NSError *error = [HttpTool inspectError:responseObject];
        if (error == nil) {
            
            NSArray *arr = [IncomeListModel mj_objectArrayWithKeyValuesArray:responseObject[@"data"][@"records"]];
            
            success(arr);
        }else{
            
            failure(error);
        }
    } failure:^(NSError *error) {
        
        failure(error);
    }];
    
}

#pragma mark - 拓展奖励
- (void)getTZJLListWithYear:(NSString *)year month:(NSString *)month day:(NSString *)day current:(NSString *)current size:(NSString *)size Success:(void(^)(NSArray *listArr))success Failure:(void(^)(NSError *error))failure{
    
    NSString *url = [NSString stringWithFormat:@"%@/api/v1/trans/expand",IP];
    NSDictionary *dic = @{
                          @"year":year,
                          @"month":month,
                          @"day":day,
                          @"current":current,
                          @"size":size
                          };
    
    [HttpTool getUrlWithString:url parameters:dic success:^(id responseObject) {
        
        NSError *error = [HttpTool inspectError:responseObject];
        if (error == nil) {
            
            NSArray *arr = [IncomeListModel mj_objectArrayWithKeyValuesArray:responseObject[@"data"][@"records"]];
            
            success(arr);
        }else{
            
            failure(error);
        }
    } failure:^(NSError *error) {
        
        failure(error);
    }];
    
}

#pragma mark - 激活奖励
- (void)getJHJLListWithYear:(NSString *)year month:(NSString *)month day:(NSString *)day current:(NSString *)current size:(NSString *)size Success:(void(^)(NSArray *listArr))success Failure:(void(^)(NSError *error))failure{
    
    NSString *url = [NSString stringWithFormat:@"%@/api/v1/trans/cash",IP];
    NSDictionary *dic = @{
                          @"year":year,
                          @"month":month,
                          @"day":day,
                          @"current":current,
                          @"size":size
                          };
    
    [HttpTool getUrlWithString:url parameters:dic success:^(id responseObject) {
        
        NSError *error = [HttpTool inspectError:responseObject];
        if (error == nil) {
            
            NSArray *arr = [BackTotalModel mj_objectArrayWithKeyValuesArray:responseObject[@"data"][@"records"]];
            
            success(arr);
        }else{
            
            failure(error);
        }
    } failure:^(NSError *error) {
        
        failure(error);
    }];
    
}

@end
